package cn.wolfcode.p2p.controller;

import cn.wolfcode.p2p.base.util.Constants;
import cn.wolfcode.p2p.bussness.query.BidRequestQueryObject;
import cn.wolfcode.p2p.bussness.service.IBidRequestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class InvestController {

    @Autowired
    private IBidRequestService bidRequestService;

    @RequestMapping("/invest")
    public String investPage(){
        return "invest";
    }

    @RequestMapping("/invest_list")
    public String investList(@ModelAttribute("qo") BidRequestQueryObject qo, Model model){
        qo.setStates(new int[]{
                Constants.BIDREQUEST_STATE_BIDDING,
                Constants.BIDREQUEST_STATE_PAYING_BACK,
                Constants.BIDREQUEST_STATE_COMPLETE_PAY_BACK
        });
        model.addAttribute("pageInfo",bidRequestService.queryList(qo));
        return "invest_list";
    }
}
